<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="/common/base.jsp"%>
<%
	AreaDao dao = new AreaDao();
	String sql ="select * from t_area ";
	Object[]params={};
	List<Area> areaList = dao.queryOjects(sql, params);

	//加载用户原有信息
	String medicalcode=request.getParameter("id");
	Medical m = new Medical(medicalcode);
	
	//级别
	GradeDao grade = new GradeDao();
	String sql2 ="select * from m_grade ";
	Object[]params2={};
	List<Grade> gradeList = grade.queryOjects(sql2, params2);
	
	//类型
	TypeDao type = new TypeDao();
	String sql1 ="select * from m_type ";
	Object[]params1={};
	List<Type> typeList = type.queryOjects(sql1, params1);
 %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="renderer" content="webkit">
<link rel="stylesheet" type="text/css" href="css/styles.css">
<link rel="stylesheet" type="text/css" href="css/admin.css">

<script type="text/javascript" src="js/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="js/admin.js"></script>
<script type="text/javascript">
	$(document).ready(function() {
		//重新绑定表单提交
		$("#add_btn").bind("click", function() {
			$('form').submit();
		});
	});
</script>

</head>

<body>
	<div class="panel admin-panel">
		<div class="panel-head" id="add">
			<strong><span class="icon-pencil-square-o"></span>增加医疗机构信息</strong>
		</div>
		<div class="body-content">
			<form id="form-add" method="post" class="form-x"
				action="<%=path%>/system/MedicalServlet?m=edit">
				<div class="form-group">
					<div class="label">
						<label>医疗机构代码：</label>
					</div>
					<div class="field">
						<input type="text" readonly="readonly" class="input w50" value="<%=m.getMedicalcode() %>" name="medicalcode"
							data-validate="required:请输入医疗机构代码" />
						<div class="tips"></div>
					</div>
				</div>
				<div class="form-group">
					<div class="label">
						<label>组织机构代码：</label>
					</div>
					<div class="field">
						<input type="text" class="input w50" value="<%=m.getOrganizecode() %>" name="organizecode"
							data-validate="required:请输入组织机构代码" />
						<div class="tips"></div>
					</div>
				</div>
				<div class="form-group">
					<div class="label">
						<label>医疗机构名称：</label>
					</div>
					<div class="field">
						<input type="text" class="input w50" value="<%=m.getMedicalname() %>" name="medicalname"
							data-validate="required:输入医疗机构名称" />
						<div class="tips"></div>
					</div>
				</div>
				<div class="form-group">
					<div class="label">
						<label>地区代码：</label>
					</div>
					<div class="field">
						<input type="text" class="input w50" value="<%=m.getDiqucode() %>" name="diqucode"
							data-validate="required:输入地区代码" />
						<div class="tips"></div>
					</div>
				</div>
				<div class="form-group">
					<div class="label">
						<label>所属行政区域：</label>
					</div>
					<div class="field">
						<select id="areacode" class="input w50" name="areacode">
						<%
							for(Area a : areaList){
						 %>
							<option value="<%=a.getAreaname()%>">
							 <%
						  
						  for(int i=0;i<a.getGrade();i++){
							 if(i==0){
								 out.print("|-"); 
							 }else{
								 out.print("-");
							 }
							  
						  } %>
							<%=a.getAreaname() %></option>
							
							<%} %>
							
						</select>
						<div class="tips"></div>
					</div>
				</div>
				<div class="form-group">
					<div class="label">
						<label>机构级别：</label>
					</div>
					<div class="field">
						<select id="grade" class="input w50" name="grade">
						<%
							for(Grade g : gradeList){
						 %>
							<option value="<%= g.getGrade()%>">
							
							<%=g.getGrade() %>
							
							<%} %>
							</option>
						</select>
						<div class="tips"></div>
					</div>
				</div>
				<div class="form-group">
					<div class="label">
						<label>卫生机构类型：</label>
					</div>
					<div class="field">
						<select id="type" class="input w50" name="type">
						<%
							for(Type t : typeList){
						 %>
							<option value="<%= t.getType()%>">
							
							<%=t.getType() %>
							
							<%} %>
							</option>
						</select>
						<div class="tips"></div>
					</div>
				</div>
				
				<div class="form-group">
					<div class="label">
						<label></label>
					</div>
					<div class="field">
						<button id="add_btn" class="button bg-main icon-check-square-o"
							type="button">提交</button>
					</div>
				</div>
			</form>
		</div>
	</div>

</body>
</html>
